home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / smaltalk / manchest.lha / MANCHESTER / manchester / 2.3 / enhanced-condense-changes.st < prev    next >
Text File  |  1993-07-24  |  3KB  |  84 lines

  1. "    NAME        enhanced-condense-changes
  2.     AUTHOR        neild@cs.man.ac.uk
  3.     FUNCTION can now rebuild image after condense 
  4.     ST-VERSIONS    2.3
  5.     PREREQUISITES     
  6.     CONFLICTS    
  7.     DISTRIBUTION      world
  8.     VERSION        1.1
  9.     DATE    22 Jan 1989
  10. SUMMARY    enhanced-condense-changes
  11.     (2.3) neild
  12.    The standard method of condensing the changes file loses all
  13.    changes to class definitions and all new class definitions. This
  14.    means an image cannot be rebuilt from a condensed changes file. The
  15.    changes here cause class definitions to be placed on the condensed
  16.    changes file as changes (in super class order). Its slower because
  17.    the changes file has to be scanned, but then how often do you
  18.    condense your changes files.
  19. "!
  20. 'From Smalltalk-80, Version 2.2 of July 4, 1987 on 4 September 1989 at 6:08:31 pm'!
  21. 'The standard method of condensing the changes file loses all changes to class
  22. definitions and all new class definitions. This means an image cannot be rebuilt
  23. >from condensed changes file. the two changes here cause class definitions to be placed
  24. on the condensed changes file as changes (in super class order).'!
  25.  
  26.  
  27. !ClassRelatedChange methodsFor: 'accessing'!
  28.  
  29. nonMetaclassName
  30.     ^((ReadStream on: className) upTo: Character space) asSymbol! !
  31.  
  32. !ChangeScanner class methodsFor: 'scanning changes files'!
  33.  
  34. classesWithChangedDefinitions
  35.     | changedClasses changesFile className | 
  36.     "Answer the set of classes whose definitions (or metaclass definitions) have been
  37.     changed, i.e. the classes of ClassDefinitionChanges etc on the changes file."
  38.     "ChangeScanner classesWithChangedDefinitions."
  39.  
  40.     changedClasses _ IdentitySet new.
  41.     SourceFiles isNil ifTrue: [ ^changedClasses ].
  42.     (changesFile _ SourceFiles at: 2) reset; readOnly.
  43.     Transcript show: 'searching for changed class definitions ...'.
  44.     self new scanFile: changesFile do: [ :aChange |
  45.         (aChange class == ClassDefinitionChange
  46.         or: [ aChange class == ClassOtherChange and: [ 'inst vars for' = aChange type ] ])
  47.             ifTrue: [
  48.                 className _ aChange nonMetaclassName.
  49.                 (Smalltalk classNames includes: className) ifTrue: [
  50.                     changedClasses add: (Smalltalk at:  className) ] ] ].
  51.     Transcript show: ' done'; cr.
  52.     changesFile setToEnd.
  53.     ^changedClasses! !
  54.  
  55. !SystemDictionary methodsFor: 'system compression'!
  56.  
  57. condenseChanges
  58.     "Move all the changes onto a compacted sources file ensuring that class
  59.     definitions appear before all other changes to a class.
  60.         Smalltalk condenseChanges."
  61.  
  62.     | f fileName changedDefinitions |
  63.     f _ FileStream fileNamed: 'temp.changes'.
  64.     f timeStamp.
  65.     Cursor wait showWhile: [
  66.         changedDefinitions _ ChangeSet superclassOrder: ChangeScanner
  67.             classesWithChangedDefinitions ].
  68.     changedDefinitions do: [ :aClass |
  69.         f nextChunkPut: aClass definition; cr; nextChunkPut: aClass class definition; cr; cr ].
  70.     Smalltalk allClassesDo: [:class |
  71.         class moveChangesTo: f.
  72.         class class moveChangesTo: f].
  73.     f close.
  74.     f readOnly.
  75.     fileName _ (SourceFiles at: 2) name.
  76.     (SourceFiles at: 2) close.
  77.     SourceFiles at: 2 put: f.
  78.     FileDirectory removeKey: fileName.
  79.     f file rename: fileName! !
  80.  
  81.                      
  82.  
  83.  
  84.